package at.tasat.solver;

public final class VariableOccurencesList implements Cloneable {

	private final VariableOccurences[] occurences;

	public VariableOccurencesList(int numberOfVariables) {
		occurences = new VariableOccurences[numberOfVariables];
		for (int variableId = 1; variableId <= occurences.length; variableId++) {
			occurences[variableId - 1] = new VariableOccurences(variableId);
		}
	}

	private VariableOccurencesList(VariableOccurences[] occurences) {
		this.occurences = occurences;
	}

	public VariableOccurences getOccurences(int variableId) {
		return occurences[variableId - 1];
	}

	public VariableOccurencesList clone() {
		VariableOccurences[] clonedOccurences = new VariableOccurences[occurences.length];
		for (int i = 0; i < occurences.length; i++) {
			clonedOccurences[i] = occurences[i].clone();
		}
		return new VariableOccurencesList(clonedOccurences);
	}
}
